#ifndef __SYSTEM_H__
#define __SYSTEM_H__

#include "types.h"
#include "ports.h"
#include "mcu.h"

void system_init(void);

void sys_timer2_install(UINT16 count);
void sys_timer2_start();
void sys_timer2_stop();

void sys_timer3_install(UINT16 count);
void sys_timer3_start();
void sys_timer3_stop();

/**
 * uart configuration
 */
#define SYS_UART_INT_DISABLE    (ES0 = 0)
#define SYS_UART_INT_ENABLE     (ES0 = 1)

#define SYS_UART_WRITE(val)     (SBUF0 = val)
#define SYS_UART_READ(val)      (val = SBUF0)

typedef enum _sys_uart_baudrate_t_
{
    SYS_UART_BAUDRATE_9600,
    SYS_UART_BAUDRATE_56000,
    SYS_UART_BAUDRATE_115200
}SYS_UART_BAUDRATE_T;

void sys_uart_init(SYS_UART_BAUDRATE_T br);
void sys_uart_start();
void sys_uart_stop();

#define UART_RECV_BUF_LENGTH 128
#define UART_SEND_BUF_LENGTH 128

BOOL sys_uart_send_byte(UINT8 sdata);
BOOL sys_uart_read_byte(UINT8* rdata);


#endif
